package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.Announcement;
import com.itheima.mapper.AnnouncementMapper;
import com.itheima.service.db.AnnouncementService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zsk
 * @create 2022-03-21-22:28
 */
@DubboService
public class AnnouncementServiceImpl implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;


    //查看公告信息
    @Override
    public PageBeanVo findByPage(Integer pageNum, Integer pageSize) {

        //设置分页条件
        Page<Announcement> page = new Page<>(pageNum,pageSize);

        //构建条件
        LambdaQueryWrapper<Announcement> wrapper = new LambdaQueryWrapper<>();

        //查询Announcement中所有数据
        announcementMapper.selectPage(page,wrapper);

        //返回分页对象
        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());
    }
}
